package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WmsWarehouseArea;
import com.ruoyi.system.domain.vo.SelectVo;
import com.ruoyi.system.mapper.WmsWarehouseAreaMapper;
import com.ruoyi.system.service.IWmsWarehouseAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 仓库区域信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-13
 */
@Service
public class WmsWarehouseAreaServiceImpl implements IWmsWarehouseAreaService
{
    @Autowired
    private WmsWarehouseAreaMapper wmsWarehouseAreaMapper;

    /**
     * 查询仓库区域信息
     *
     * @param areaId 仓库区域信息主键
     * @return 仓库区域信息
     */
    @Override
    public WmsWarehouseArea selectWmsWarehouseAreaByAreaId(Long areaId)
    {
        return wmsWarehouseAreaMapper.selectWmsWarehouseAreaByAreaId(areaId);
    }

    /**
     * 查询仓库区域信息列表
     *
     * @param wmsWarehouseArea 仓库区域信息
     * @return 仓库区域信息
     */
    @Override
    public TableDataInfo<WmsWarehouseArea> selectWmsWarehouseAreaList(WmsWarehouseArea wmsWarehouseArea, PageQuery pageQuery)
    {
        Page<WmsWarehouseArea> page = wmsWarehouseAreaMapper.selectWmsWarehouseAreaList(pageQuery.build(),wmsWarehouseArea);
        return TableDataInfo.build(page);
    }

    /**
     * 新增仓库区域信息
     *
     * @param wmsWarehouseArea 仓库区域信息
     * @return 结果
     */
    @Override
    public int insertWmsWarehouseArea(WmsWarehouseArea wmsWarehouseArea)
    {
        wmsWarehouseArea.setCreateTime(DateUtils.getNowDate());
        return wmsWarehouseAreaMapper.insertWmsWarehouseArea(wmsWarehouseArea);
    }

    /**
     * 修改仓库区域信息
     *
     * @param wmsWarehouseArea 仓库区域信息
     * @return 结果
     */
    @Override
    public int updateWmsWarehouseArea(WmsWarehouseArea wmsWarehouseArea)
    {
        wmsWarehouseArea.setUpdateTime(DateUtils.getNowDate());
        return wmsWarehouseAreaMapper.updateWmsWarehouseArea(wmsWarehouseArea);
    }

    /**
     * 批量删除仓库区域信息
     *
     * @param areaIds 需要删除的仓库区域信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseAreaByAreaIds(Long[] areaIds)
    {
        return wmsWarehouseAreaMapper.deleteWmsWarehouseAreaByAreaIds(areaIds);
    }

    /**
     * 删除仓库区域信息信息
     *
     * @param areaId 仓库区域信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseAreaByAreaId(Long areaId)
    {
        return wmsWarehouseAreaMapper.deleteWmsWarehouseAreaByAreaId(areaId);
    }


    @Override
    public List<SelectVo> getWarehouseAreaSelect(){
        return wmsWarehouseAreaMapper.getWarehouseAreaSelect(null);
    }


    @Override
    public List<SelectVo> getWarehouseAreaSelectByWarehouseId(Long warehouseId){
        return wmsWarehouseAreaMapper.getWarehouseAreaSelect(warehouseId);
    }
}
